package xdu.lz.comsumer;

import org.apache.catalina.core.ApplicationContext;
import xdu.lz.framework.ProxyFactory;
import xdu.lz.provider.api.HelloService;

public class Consumer {

    public static void main(String[] args) {
        //1自己手动封装Invocation
//        HttpClient httpClient = new HttpClient();
//        RequestWrap invocation
//                = new RequestWrap(HelloService.class.getName(),
//                "sayHello",new Class[]{String.class},new String[]{"perdu"});
//        String result = httpClient.refer("localhost", 8080, invocation);
//        System.out.println("result = " + result);

        //2模拟Spring，通过反射包装Invocation
        HelloService helloService = (HelloService) ProxyFactory.getProxy(HelloService.class);
        for (;;) {
            try {
                String result = helloService.sayHello("周瑜");
                System.out.println(result);
                Thread.sleep(100);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    }
}
